{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1ee73d7d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:16:02.657818Z",
     "start_time": "2023-05-28T04:16:02.468863Z"
    }
   },
   "outputs": [],
   "source": [
    "import torch\n",
    "from torch import nn\n",
    "from torchvision import models\n",
    "from IPython.display import Image"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1993a19-f0c7-4511-a397-485eb703d0ce",
   "metadata": {},
   "source": [
    "## basics"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66b3c8e1-0ca0-4c91-8a10-73c4c38bae5f",
   "metadata": {},
   "source": [
    "$$\n",
    "y=xA^T+b\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3cdc9f53-7e53-4672-a46f-71432820d1df",
   "metadata": {},
   "source": [
    "- fan in fan out （扇入扇出）\n",
    "    - 刻画 parameter（weights）的 shape；\n",
    "    - 以 `nn.Linear` 为例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fdd133e6-10e2-438d-8198-1cc00a34d548",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"./imgs/linear.png\" width=\"400\"/>"
      ],
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Image(url='./imgs/linear.png', width=400)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f98cd1d0-9f1f-47a9-b4f0-720e719f526a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"./imgs/fan_in_fan_out.png\" width=\"400\"/>"
      ],
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Image(url='./imgs/fan_in_fan_out.png', width=400)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0f23d91",
   "metadata": {},
   "source": [
    "## parameters，modules"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "287f7841",
   "metadata": {},
   "source": [
    "- 返回的都是 generator（因为深度学习的 layer 较多，且会返回 weights）\n",
    "    - 所以是逐个取的，不是一次性全部加载到内存里边；\n",
    "- `m.parameters()` 与 `m.named_parameters()` \n",
    "    - 长度一致，只是 `m.named_parameters()` 多了 layer name 的属性值返回\n",
    "- `m.named_parameters()` 与 `m.named_modules()`\n",
    "    - `named_modules` 是 module 或者叫 layer 粒度，而不是 weight/bias 粒度；\n",
    "    - `named_modules` 先整体 (`[0]`) 再细节，因为大的是module，小的也是module"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "674e5fe3",
   "metadata": {},
   "source": [
    "## test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7efcefb2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:16:33.583193Z",
     "start_time": "2023-05-28T04:16:33.305636Z"
    }
   },
   "outputs": [],
   "source": [
    "model = models.resnet34()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "58f4e478",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:16:49.415722Z",
     "start_time": "2023-05-28T04:16:49.411249Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "110"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(list(model.parameters()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c31130b8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:16:58.142659Z",
     "start_time": "2023-05-28T04:16:58.135352Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "110"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(list(model.named_parameters()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f88dd803",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:17:11.491472Z",
     "start_time": "2023-05-28T04:17:11.483517Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "116"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(list(model.named_modules()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "d18e4256",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:17:42.344812Z",
     "start_time": "2023-05-28T04:17:42.332805Z"
    }
   },
   "outputs": [],
   "source": [
    "# list(model.named_modules())[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2a87cbf7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:17:52.756158Z",
     "start_time": "2023-05-28T04:17:52.747790Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('conv1',\n",
       " Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False))"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(model.named_modules())[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "113334a1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-05-28T04:19:12.895924Z",
     "start_time": "2023-05-28T04:19:12.889671Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('conv1.weight',\n",
       " Parameter containing:\n",
       " tensor([[[[-3.8716e-02,  1.9200e-02, -3.3659e-02,  ...,  4.3175e-03,\n",
       "             7.5653e-04,  2.6480e-02],\n",
       "           [-2.1792e-02,  6.7750e-02,  4.2615e-03,  ...,  3.4774e-03,\n",
       "             2.3442e-02,  7.0887e-02],\n",
       "           [-1.7107e-02, -5.7436e-03,  3.3052e-02,  ...,  4.5731e-02,\n",
       "            -2.2160e-02,  1.0530e-02],\n",
       "           ...,\n",
       "           [ 1.8977e-02, -7.4217e-04,  1.2923e-02,  ..., -6.1437e-03,\n",
       "             2.6563e-02, -1.2856e-02],\n",
       "           [ 2.0856e-02, -9.5018e-03, -1.7576e-02,  ..., -1.0873e-02,\n",
       "            -5.1608e-02,  3.8118e-03],\n",
       "           [ 3.9641e-02,  1.1401e-02, -4.7437e-02,  ...,  3.3843e-02,\n",
       "            -4.7512e-02, -4.9724e-03]],\n",
       " \n",
       "          [[-2.7384e-02, -2.0644e-03, -2.2485e-02,  ..., -6.0075e-02,\n",
       "            -2.1598e-02, -2.9929e-02],\n",
       "           [ 3.5728e-03, -5.4750e-02,  2.4817e-03,  ..., -6.1871e-02,\n",
       "             2.5705e-02,  2.5756e-02],\n",
       "           [-3.3757e-02,  5.1204e-02, -4.5487e-04,  ..., -8.7942e-03,\n",
       "             4.1975e-02, -2.1295e-02],\n",
       "           ...,\n",
       "           [-8.5009e-03, -3.8225e-03, -4.5765e-03,  ..., -2.0451e-03,\n",
       "            -2.0035e-03, -1.2846e-02],\n",
       "           [-3.6134e-03, -5.2887e-03,  6.7436e-03,  ..., -1.8614e-02,\n",
       "            -1.1423e-02, -1.6813e-02],\n",
       "           [-1.3486e-02,  7.7679e-03,  3.5949e-03,  ...,  5.4425e-03,\n",
       "            -1.1174e-02, -2.2682e-02]],\n",
       " \n",
       "          [[-3.1285e-02,  2.5393e-02, -5.5923e-02,  ..., -1.8244e-02,\n",
       "            -3.4034e-02, -1.2123e-02],\n",
       "           [-3.4726e-02,  1.3295e-02,  6.4977e-03,  ...,  5.3946e-02,\n",
       "            -8.0161e-03, -2.2284e-02],\n",
       "           [-2.9764e-02, -2.3128e-02,  5.2609e-02,  ..., -1.5704e-02,\n",
       "             3.9982e-02, -1.3106e-02],\n",
       "           ...,\n",
       "           [ 1.9140e-02,  1.2808e-02, -1.6450e-02,  ...,  2.9775e-02,\n",
       "             1.2702e-02, -3.1043e-02],\n",
       "           [-8.4272e-03,  7.2676e-03, -2.5589e-02,  ...,  4.2580e-03,\n",
       "             1.8997e-02, -2.3803e-02],\n",
       "           [-6.3066e-02,  6.5276e-03, -2.3854e-02,  ..., -1.4804e-02,\n",
       "             1.1364e-02, -2.7476e-02]]],\n",
       " \n",
       " \n",
       "         [[[ 1.6305e-02, -3.1833e-02,  1.4962e-02,  ...,  2.8915e-02,\n",
       "             1.4549e-02, -2.4917e-02],\n",
       "           [ 2.3770e-04,  8.8374e-03,  1.2921e-02,  ...,  1.5199e-02,\n",
       "             7.6514e-03, -6.9715e-03],\n",
       "           [ 1.3366e-02,  8.7001e-03, -2.2769e-03,  ...,  5.1925e-02,\n",
       "             3.0947e-02,  1.3702e-02],\n",
       "           ...,\n",
       "           [ 8.2053e-03, -7.9581e-03, -3.9722e-02,  ...,  5.2086e-02,\n",
       "            -3.2872e-02, -3.2247e-02],\n",
       "           [-1.1714e-02,  4.4047e-03, -2.4661e-02,  ..., -3.8446e-02,\n",
       "             1.7781e-02,  6.9448e-03],\n",
       "           [-2.6965e-02, -3.0205e-02,  1.3406e-03,  ...,  2.7419e-02,\n",
       "            -9.4835e-04, -5.5732e-02]],\n",
       " \n",
       "          [[-3.4499e-02,  1.9259e-03,  1.6313e-02,  ...,  2.0949e-02,\n",
       "             2.7786e-02,  2.8145e-02],\n",
       "           [ 2.1737e-02, -7.6050e-02,  2.2499e-02,  ...,  3.6711e-03,\n",
       "             2.7311e-02, -1.2760e-02],\n",
       "           [-4.2594e-02,  4.5483e-02,  1.0562e-02,  ..., -4.1457e-02,\n",
       "            -8.5165e-03,  1.5016e-02],\n",
       "           ...,\n",
       "           [ 6.2844e-03, -2.5603e-02, -1.7255e-02,  ...,  2.4382e-02,\n",
       "             4.0031e-03,  3.0337e-02],\n",
       "           [-9.4653e-02, -2.9059e-02,  6.4215e-03,  ..., -2.9702e-03,\n",
       "            -7.7902e-05,  5.2857e-02],\n",
       "           [-4.0089e-03, -3.8851e-03, -1.2430e-02,  ..., -2.2824e-02,\n",
       "             6.6715e-03, -2.0029e-02]],\n",
       " \n",
       "          [[ 6.4508e-02, -6.2509e-03, -1.0171e-02,  ..., -2.0678e-03,\n",
       "            -2.3580e-02,  3.1460e-02],\n",
       "           [ 7.8545e-03,  9.7218e-03, -3.0829e-02,  ..., -3.4769e-02,\n",
       "            -4.0768e-03, -6.7038e-03],\n",
       "           [-2.5719e-02, -1.4507e-02,  3.5058e-02,  ..., -4.4428e-02,\n",
       "             5.2997e-03,  1.5528e-02],\n",
       "           ...,\n",
       "           [-1.1300e-02, -4.8682e-03, -4.0636e-02,  ...,  2.7696e-02,\n",
       "            -1.8507e-02, -2.4521e-02],\n",
       "           [-4.2929e-03,  4.0748e-02, -2.8845e-02,  ...,  2.0645e-02,\n",
       "             2.7371e-04,  5.3746e-03],\n",
       "           [-9.3062e-03, -3.1858e-02, -1.5889e-03,  ..., -4.3021e-03,\n",
       "             4.9002e-03,  1.0629e-02]]],\n",
       " \n",
       " \n",
       "         [[[-4.7750e-02,  2.3573e-02,  5.8035e-03,  ...,  3.1692e-03,\n",
       "            -1.9817e-02, -1.3703e-02],\n",
       "           [ 2.1048e-02,  1.1341e-02,  4.3818e-02,  ...,  2.7864e-02,\n",
       "            -2.2378e-02, -8.0812e-03],\n",
       "           [ 1.8167e-03,  7.6417e-03, -3.9113e-02,  ...,  1.8888e-02,\n",
       "            -2.6662e-02, -9.1038e-03],\n",
       "           ...,\n",
       "           [ 2.0118e-02, -6.8262e-03,  2.5149e-02,  ..., -2.4902e-02,\n",
       "             1.6838e-02,  4.1802e-05],\n",
       "           [-4.0746e-02, -1.1038e-02, -5.8812e-03,  ...,  4.0745e-02,\n",
       "             5.5125e-03,  9.5274e-03],\n",
       "           [-2.9769e-03,  4.9776e-02, -6.8566e-03,  ...,  1.8260e-02,\n",
       "             2.3848e-02, -1.7553e-02]],\n",
       " \n",
       "          [[ 4.7302e-02, -2.1665e-02, -2.4146e-02,  ..., -2.7835e-02,\n",
       "             2.7704e-02, -1.8479e-02],\n",
       "           [ 4.6419e-03, -2.9144e-02,  5.1156e-02,  ...,  9.3024e-03,\n",
       "            -1.1586e-02, -2.2640e-03],\n",
       "           [ 5.3064e-04,  1.0584e-02,  5.4256e-02,  ..., -1.2368e-02,\n",
       "            -2.2375e-02,  2.9857e-03],\n",
       "           ...,\n",
       "           [-4.3927e-02,  3.1122e-04,  3.1255e-03,  ...,  2.4192e-02,\n",
       "            -1.3462e-03, -1.9411e-02],\n",
       "           [-5.0733e-02, -1.7728e-02, -6.3797e-03,  ...,  2.2787e-03,\n",
       "             2.7323e-02,  2.4097e-02],\n",
       "           [ 6.8259e-03,  1.1056e-02, -2.1006e-03,  ..., -2.0176e-02,\n",
       "            -1.3331e-03,  6.6493e-03]],\n",
       " \n",
       "          [[ 5.4879e-02, -1.0267e-02,  8.8046e-03,  ...,  1.7888e-02,\n",
       "             1.6638e-02, -8.5663e-02],\n",
       "           [-8.9595e-03, -1.6460e-02,  5.0274e-02,  ..., -3.3706e-02,\n",
       "             1.1630e-03, -1.5144e-02],\n",
       "           [ 4.5977e-02, -5.9890e-02,  3.1166e-02,  ...,  6.4245e-02,\n",
       "            -2.8901e-03,  3.7062e-03],\n",
       "           ...,\n",
       "           [ 2.3456e-02, -6.2058e-03,  6.1860e-04,  ...,  9.9433e-03,\n",
       "             1.3464e-02,  5.7635e-03],\n",
       "           [-1.4140e-02,  1.2885e-02, -1.9262e-02,  ..., -2.7786e-02,\n",
       "             3.1290e-02, -2.6861e-02],\n",
       "           [-3.2163e-02, -1.9197e-02, -3.6517e-02,  ..., -8.5275e-03,\n",
       "            -3.6954e-02,  2.8348e-02]]],\n",
       " \n",
       " \n",
       "         ...,\n",
       " \n",
       " \n",
       "         [[[-1.2878e-02, -4.1148e-03,  9.8089e-03,  ...,  7.5688e-03,\n",
       "             3.0542e-02, -1.9504e-02],\n",
       "           [ 1.3204e-02, -2.2706e-02, -4.5120e-03,  ...,  5.7283e-03,\n",
       "             1.4403e-02, -3.5218e-02],\n",
       "           [-5.6780e-03,  3.8898e-03,  1.6608e-02,  ..., -5.8338e-02,\n",
       "            -9.4390e-03,  2.3642e-02],\n",
       "           ...,\n",
       "           [-4.5473e-02,  3.2757e-02,  6.7433e-04,  ...,  2.7103e-02,\n",
       "            -2.0038e-02,  9.4915e-03],\n",
       "           [-2.7102e-02, -1.5379e-02, -2.5230e-02,  ..., -3.9198e-02,\n",
       "            -2.4026e-02,  4.9102e-03],\n",
       "           [ 1.9780e-02,  1.5527e-02, -2.9001e-02,  ...,  2.7298e-02,\n",
       "             1.9077e-02,  1.1685e-02]],\n",
       " \n",
       "          [[-8.4900e-03,  2.5181e-02, -2.3246e-03,  ..., -1.0555e-02,\n",
       "            -1.6983e-02,  1.7890e-02],\n",
       "           [ 3.9287e-02,  1.4065e-02, -3.0394e-02,  ..., -3.1196e-02,\n",
       "             1.3745e-02,  1.3725e-02],\n",
       "           [-7.9453e-03, -3.1221e-02,  3.2467e-02,  ..., -1.5310e-02,\n",
       "            -8.8093e-03, -3.8527e-02],\n",
       "           ...,\n",
       "           [ 3.8039e-02,  2.1327e-02,  2.0187e-02,  ..., -3.5477e-02,\n",
       "             7.7416e-03,  4.5587e-02],\n",
       "           [-2.5006e-02, -5.7992e-02,  5.0564e-02,  ..., -8.5681e-03,\n",
       "            -2.1653e-02,  2.2317e-02],\n",
       "           [-3.4876e-02,  3.1488e-02, -2.8119e-02,  ...,  3.0928e-02,\n",
       "            -3.4287e-02, -1.8462e-02]],\n",
       " \n",
       "          [[ 2.7241e-02, -3.1843e-02,  1.7379e-02,  ...,  2.7525e-03,\n",
       "            -2.2778e-02, -4.2839e-02],\n",
       "           [ 7.6563e-03, -1.0332e-02,  2.2303e-02,  ...,  5.9414e-02,\n",
       "            -1.5486e-02,  9.1413e-03],\n",
       "           [-3.2446e-02,  8.2476e-03, -4.7309e-02,  ..., -1.6981e-02,\n",
       "             4.5196e-03, -3.8570e-03],\n",
       "           ...,\n",
       "           [ 1.3832e-02,  4.9303e-03, -7.9868e-03,  ...,  1.0444e-02,\n",
       "            -3.8583e-02, -4.6248e-03],\n",
       "           [-4.3983e-02,  3.5020e-02, -6.8022e-03,  ...,  4.9501e-02,\n",
       "             1.4740e-02, -2.1576e-02],\n",
       "           [ 2.1603e-03, -2.1882e-02, -3.2566e-02,  ...,  1.8747e-02,\n",
       "             1.7011e-02,  5.3909e-02]]],\n",
       " \n",
       " \n",
       "         [[[ 4.0314e-03, -2.8020e-02, -4.0513e-03,  ..., -6.1647e-02,\n",
       "            -1.4066e-02,  3.0319e-02],\n",
       "           [-3.2021e-03,  9.1428e-03, -4.4362e-02,  ..., -5.9342e-03,\n",
       "             7.7763e-03,  2.9033e-03],\n",
       "           [ 1.9085e-03, -2.4052e-02, -4.8134e-02,  ...,  3.9674e-02,\n",
       "             4.5834e-02, -3.2465e-02],\n",
       "           ...,\n",
       "           [ 3.3786e-02,  1.1367e-02,  1.1887e-02,  ..., -4.0641e-03,\n",
       "             1.6742e-02, -4.1349e-04],\n",
       "           [-2.7156e-02, -3.2011e-02,  2.6167e-02,  ...,  4.2771e-02,\n",
       "             4.5265e-03, -2.6342e-02],\n",
       "           [ 1.8170e-02, -1.0659e-03, -1.2165e-02,  ..., -3.0151e-02,\n",
       "             1.2900e-02,  4.1742e-02]],\n",
       " \n",
       "          [[-1.0260e-02, -1.2033e-02,  2.4549e-02,  ...,  5.1132e-02,\n",
       "            -1.2209e-02,  5.3424e-02],\n",
       "           [ 8.5099e-03, -1.9709e-02,  2.2096e-02,  ...,  3.0940e-02,\n",
       "            -3.8899e-02,  3.8276e-02],\n",
       "           [ 9.4966e-03, -6.5120e-02,  3.4037e-02,  ..., -2.3914e-02,\n",
       "            -2.3992e-02, -3.4772e-02],\n",
       "           ...,\n",
       "           [ 3.2878e-04,  3.5325e-02, -3.5851e-03,  ..., -1.2002e-02,\n",
       "             4.0578e-04, -4.1449e-03],\n",
       "           [ 1.0107e-04, -1.7863e-02, -1.8993e-02,  ..., -1.0596e-02,\n",
       "             3.9824e-02, -2.9673e-02],\n",
       "           [ 2.9718e-02,  1.6327e-02,  5.9966e-03,  ..., -3.6777e-02,\n",
       "             5.3366e-02, -3.6664e-03]],\n",
       " \n",
       "          [[-1.1692e-02,  4.5272e-02, -3.6895e-02,  ..., -1.7360e-04,\n",
       "            -1.2102e-02,  3.2259e-02],\n",
       "           [ 2.0923e-03, -1.1060e-02,  2.9855e-02,  ..., -5.0468e-02,\n",
       "             2.7334e-02, -5.1278e-03],\n",
       "           [ 4.8385e-02,  5.7398e-02,  5.5119e-03,  ..., -3.7065e-02,\n",
       "            -5.4104e-02, -3.1775e-03],\n",
       "           ...,\n",
       "           [-1.9985e-02, -3.6005e-02,  1.0738e-02,  ..., -3.2706e-02,\n",
       "            -1.7321e-02, -1.7253e-02],\n",
       "           [ 3.6501e-02,  2.0267e-02, -3.7122e-02,  ...,  4.2068e-02,\n",
       "             1.6946e-02, -7.8994e-03],\n",
       "           [-4.5942e-04, -1.0085e-02,  2.6462e-02,  ...,  7.1992e-03,\n",
       "             3.8779e-03, -2.6681e-02]]],\n",
       " \n",
       " \n",
       "         [[[-1.5695e-02, -1.1126e-02,  9.0382e-03,  ..., -1.6947e-03,\n",
       "            -1.7372e-02, -1.1299e-02],\n",
       "           [ 4.8453e-02, -5.0642e-03,  3.1937e-02,  ...,  4.2061e-02,\n",
       "            -1.1043e-02,  1.7808e-02],\n",
       "           [ 1.1454e-02,  5.9184e-02,  7.3168e-03,  ..., -1.5257e-02,\n",
       "            -4.9742e-02,  2.8735e-02],\n",
       "           ...,\n",
       "           [-2.6911e-02,  3.1642e-02,  4.7749e-03,  ..., -3.3852e-02,\n",
       "            -5.6840e-03, -6.4548e-03],\n",
       "           [ 3.9194e-03, -4.9959e-03, -1.7425e-02,  ..., -1.6630e-02,\n",
       "            -6.5434e-03, -1.7544e-02],\n",
       "           [ 2.6716e-04, -1.7736e-02,  2.3194e-02,  ...,  1.6104e-02,\n",
       "            -2.5324e-02,  2.0717e-02]],\n",
       " \n",
       "          [[-7.4231e-03, -7.0875e-02, -1.2880e-02,  ..., -1.9167e-02,\n",
       "             8.3802e-03,  2.8303e-02],\n",
       "           [ 5.7474e-02,  1.3194e-02,  8.5764e-03,  ..., -2.2904e-02,\n",
       "            -6.3102e-04,  2.2133e-02],\n",
       "           [ 4.1157e-02,  1.3833e-02, -2.8785e-03,  ..., -5.1186e-02,\n",
       "            -1.9028e-03, -7.0052e-02],\n",
       "           ...,\n",
       "           [-1.7734e-02,  9.1522e-03,  9.5196e-03,  ..., -9.8150e-03,\n",
       "            -4.0959e-03,  7.3275e-03],\n",
       "           [-9.6928e-05,  5.1648e-02,  1.4997e-02,  ..., -3.9696e-02,\n",
       "            -1.9732e-02, -1.6258e-02],\n",
       "           [ 2.2613e-02,  5.0937e-04, -4.0529e-02,  ..., -2.2341e-02,\n",
       "             2.6919e-02,  6.2886e-02]],\n",
       " \n",
       "          [[ 2.2851e-02,  3.9081e-02,  7.1821e-03,  ...,  9.7758e-03,\n",
       "             3.2171e-02, -4.3528e-02],\n",
       "           [ 1.3011e-02,  3.1287e-02, -1.0433e-02,  ...,  1.3596e-02,\n",
       "             6.4658e-02, -2.8156e-02],\n",
       "           [ 1.6573e-02,  2.9062e-02, -8.2303e-03,  ...,  6.1311e-02,\n",
       "             3.8007e-02, -3.1408e-03],\n",
       "           ...,\n",
       "           [-3.4472e-02, -1.2807e-02, -3.0409e-03,  ..., -1.6196e-03,\n",
       "            -1.0024e-02, -7.8249e-02],\n",
       "           [ 1.8374e-02, -1.2237e-03, -2.2987e-02,  ...,  1.4725e-02,\n",
       "            -8.3186e-03,  3.4942e-02],\n",
       "           [ 6.0037e-03,  1.5234e-02,  2.1906e-02,  ..., -1.3031e-02,\n",
       "             2.0452e-02, -6.3938e-05]]]], requires_grad=True))"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(model.named_parameters())["
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
